package org.bhavani.duplicateEleArray;

import java.util.Arrays;

public class DupArrayRem {
	char[] charArray;

	public char[] removeDuplicates(char[] charArray){
		Arrays.sort(charArray);
		int i = 0;
		char[] newArray = new char[charArray.length];
		for ( i = 0; i < charArray.length-1; i++) {
			if( charArray[i] != charArray[i+1]){
				newArray[i] = charArray[i];
			}
		}
		newArray[i] = charArray[charArray.length - 1];

		return newArray;

	}
	public static void main(String ars[]){
   	 char[] numOfArray ={'2','5','2','4','2','3','2','1'};
   	DupArrayRem duplicate = new DupArrayRem();
   	char[] dup = duplicate.removeDuplicates( numOfArray );
   	for (int i = 0; i < dup.length; i++) {
   		System.out.print(dup[i]);
			
		}
    }
}
